package category;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadTest {
    private static final InheritableThreadLocal<String> inheritable = new InheritableThreadLocal<>();

    public static void main(String[] args) {
        inheritable.set("first");
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(8);
        fixedThreadPool.submit(() -> {
            inheritable.set("second");
            System.out.println("threadOne: " + inheritable.get());
            inheritable.remove();
        });
        fixedThreadPool.submit(() -> System.out.println("threadTwo: " + inheritable.get()));
        System.out.println("threadMain: " + inheritable.get());
        fixedThreadPool.shutdown();
    }
}
